<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>基本信息</title>
<link href="css/personalcenter/basicinformation.css" rel="stylesheet"
	type="text/css" />
<script src="js/index/jquery-2.1.3.min.js"></script>


<script type="text/javascript">
	function ismobile()

	//		
	{
		var phone = $("input[name=phone]").val();
		//alert(phone);
		var uphone = ${user.phone}
		
	
		if (phone == uphone) {
			alert("新旧手机号码一致，请重新输入");
			$("input[name=phone]").focus();
			return false;
		}
		//		
		if (phone.length != 11) {
			alert('请输入合法的手机号码！');
			$("input[name=phone]").focus();

			return false;
		}
		//	    
		var myreg = /^(((13[0-9]{1})|159|158|157|156|155|153|150|151|159|182|185|187|188|189|186|145|176)+\d{8})$/;
		if (!myreg.test(phone)) {
			alert('请输入合法的手机号码！');
			$("input[name=phone]").focus();

			return false;
		}
		//	    return true;
		var s = $("#ss").val();
		$.ajax({
			url : "cps",
			type : "get",
			data : {
				phone2 : s
			},
			datatype : "json",
			success : function(e) {
				alert(JSON.stringify(e));
			}

		});

	}
</script>
</head>

<body>
	<div class="wrap_right">

		<div class="wrap_right1">
			<span>基本资料：</span>
		</div>
		<div class="wrap_right2">
			<ul>
				<li><span>姓名:</span>
					<div class="wrap_right2_div">
						<input class="wrap_right2_input" disabled="disabled"
							value="${user.name}" />
					</div></li>


				<li><span>电话:</span>
					<div class="wrap_right2_div">
						<input class="wrap_right2_input" value="${user.phone}" id="ss"
							name="phone" />
					</div></li>


				<li><span style="margin-left: 90px;">身份证号码:</span>
					<div class="wrap_right2_div">
						<input class="wrap_right2_input" disabled="disabled"
							value="${user.idcard}" />
					</div></li>


				<li><input type="button" value="保存" class="wrap_right2_button"
					onclick="ismobile()"></li>

				<div id="wrap_right2_img">
					<img src="${user.image}" style="width:180px;height:200px" />
					<form method="post" enctype="multipart/form-data" id="imgform">
						<input type="file" name="f"> <input type="button"
							value="上传" class="uploadImg">
					</form>
				</div>

			</ul>
		</div>

	</div>
</body>
<script type="text/javascript">
	$(function() {
		//上传图片按钮点击事件
		$(".uploadImg").click(function() {
			var formData = new FormData($("#imgform")[0]);
			//ajax请求
			$.ajax({
				url : "/fuhe/fileservlet",
				type : "POST",
				data:formData,
				async : false,
				cache : false,
				contentType : false,
				processData : false,
				success : function(returndata) {
					//上传成功，修改图片
					$("#wrap_right2_img img").attr("src",returndata);
				},
				error : function(returndata) {
					alert("上传失败!");
				}
			})
		})
	})
</script>
</html>